<ui:component xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:o="http://openfaces.org">
	
	<h:form id="frmSimpleSelectLandUse">
		<h:panelGroup id="funCompleteSelection" rendered="#{not simpleLandUseHelper.landUseNameInputFieldName.equals('')}">
			<script type="text/javascript">
				function completeSelection() {
					#{rich:element(simpleLandUseHelper.landUseNameInputFieldName)}.value = '#{simpleLandUseHelper.selectedNameStr}';
					//document.getElementById('#{simpleLandUseHelper.landUseNameInputFieldName}').value = '#{simpleLandUseHelper.selectedNameStr}';
					#{rich:component('selectLandUsePanel')}.hide();
				}
			</script>
		</h:panelGroup>
		
		<h:panelGroup id="frmSimpleLandUse">
			<rich:toolBar style="height:25px">
				<rich:toolBarGroup location="left">
					<h:outputText value="Nivel: #{simpleLandUseHelper.currentLevel}" />
				</rich:toolBarGroup>
				<rich:toolBarGroup location="left">
				</rich:toolBarGroup>
				<rich:toolBarGroup location="right">
					<a4j:commandLink
						value="Nivel superior"
						action="#{simpleLandUseHelper.rollUp}"
						reRender="frmLandUse"
						rendered="#{simpleLandUseHelper.currentLevel gt 0}">
					</a4j:commandLink>
				</rich:toolBarGroup>
			</rich:toolBar>	
			
			<br />
			<br />
			
			<div style="width:100%;height:420px;overflow:auto;">
				<rich:dataTable id="dtLandUse" var="lu" value="#{simpleLandUseHelper.landUseList}" rows="15" width="100%" columnsWidth="10%,70%,20%">
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Codigo" />
						</f:facet>
						<h:outputText value="#{lu.completeCode}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Nombre" />
						</f:facet>
						<a4j:commandLink
							value="#{lu.name}"
							action="#{simpleLandUseHelper.drillDown(lu)}"
							reRender="frmLandUse"
							rendered="#{not lu.leaf}">
						</a4j:commandLink>
						<h:outputText value="#{lu.name}" rendered="#{lu.leaf}" />
					</rich:column>
					<rich:column>
						<a4j:commandLink
							value="Seleccionar!"
							rendered="#{simpleLandUseHelper.landUseNameInputFieldName.equals('')}"
							action="#{simpleLandUseHelper.select(lu)}"
							reRender="#{simpleLandUseHelper.reRenderComponents}"
							oncomplete="if (#{facesContext.maximumSeverity == null}) #{rich:component('simpleSelectLandUsePanel')}.hide(); else #{rich:component('msgPanel')}.show();">
						</a4j:commandLink>
						<a4j:commandLink
							value="Seleccionar"
							rendered="#{not simpleLandUseHelper.landUseNameInputFieldName.equals('')}"
							action="#{simpleLandUseHelper.select(lu)}"
							reRender="funCompleteSelection"
							oncomplete="completeSelection()">
						</a4j:commandLink>
					</rich:column>
				</rich:dataTable>
			</div>
		</h:panelGroup>
		<br/>
	</h:form>
</ui:component>
